package labox.innovation.gameserver.skills.conditions;

import labox.innovation.gameserver.model.L2Effect;
import labox.innovation.gameserver.skills.Env;

public class ConditionTargetActiveEffectId extends Condition {

	private final int _effectId;
	private final int _effectLvl;

	public ConditionTargetActiveEffectId(int effectId) {
		_effectId = effectId;
		_effectLvl = -1;
	}

	public ConditionTargetActiveEffectId(int effectId, int effectLevel) {
		_effectId = effectId;
		_effectLvl = effectLevel;
	}

	@Override
	public boolean testImpl(Env env) {
		for (L2Effect e : env.target.getAllEffects()) {
			if (e != null) {
				if (e.getSkill().getId() == _effectId) {
					if (_effectLvl == -1 || _effectLvl <= e.getSkill().getLevel())
						return true;
				}
			}
		}
		return false;
	}
}
